home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 2,801 to 2,900 / aol-file-protocol-4400-2801-to-2900.zip / AOLDLs / C++ Files Library / Direct Blitting in C++ / Blitting.sit / Blitting ƒ / About CDirectBlit next >
Text File  |  1995-04-29  |  3KB  |  36 lines

  1. The Direct Blitting Class Library for the MacOS
  2.  
  3. No matter what you are doing, the direct approach is almost always the best approach. As it turns out, animation is not an exception to this rule. Unfortunately, the direct approach is not always the easiest. The following classes will help you to make direct blitting easier, faster, and more compatible for you.
  4.  
  5. The classes depend highly on C++ and the Macintosh toolbox, so some knowledge of both are necessary. The direct blitting classes are derived from one base: CDirectBlit. CDirectBlit╒s sub-classes are currently CDirectGWorld and CDirectVideo. The CDirectBlit class is responsible for accessing blitting information and toolbox information, while its sub-classes are responsible for setting up where the memory will be used. The CDirectGWorld class makes use of QuickDraw's offscreen GWorlds, and the CDirectVideo class makes use of onscreen CGrafPorts and device PixMaps. There is also a CCopier class, which helps you copy from one CDirectBlit to the next. Stack based GWorld setters and MMU mode swappers are also provided, modeled after classes like StHandleLocker.
  6.  
  7. Setting up a GWorld and an onscreen blitting area is easy to do. Here, for example, is how one would allocate memory for a GWorld that is ready to be directly accessed:
  8.  
  9.     CDirectGWorld offscreen( bounds, kEightBit );
  10.  
  11. where bounds is a QuickDraw rectangle describing the coordinates of the GWorld, and where kEightBit describes the desired bit depth. Function overloading and default parameters are
  12. used to make coding easier for you. Setting up an area in video memory to directly access is also easy to do:
  13.  
  14.     CDirectVideo onscreen( GetMainDevice(), global_bounds );
  15.  
  16. where the first constructor parameter is the device that you want to directly access (in this case the main device, the one with the menubar), and where global_bounds is a global QuickDraw rectangle that describes the coordinates of the area that you want to access.
  17.  
  18. You can use CCopier instead of CopyBits, here is the constuction of one:
  19.  
  20.     CCopier copyAtoB( &A, &B );
  21.  
  22. where A is a CDirectBlit, and B is a CDirectBlit. The function call operator is overloaded to invoke copying:
  23.  
  24.     copyAtoB( &sourceRect, &destRect );
  25.  
  26. There are two default parameters for the CCopier constructor, the third parameter describes the copy method (how the pixels are moved in memory). To bypass CopyBits, do this:
  27.  
  28.     CCopier copyAtoB( &A, &B, kDirect8To8 );
  29.  
  30. Keep in mind that the above copy method only works when both CDirectBlits are 8-bit. In the future, an 8-bit to 4-bit converter will be made, to help programmers support 16 shades of gray in their programs. The CCopier class may radically change in the future, making it more aware at run-time, and maybe turning it into a global function (as demand for it to be like CopyBits is high).
  31.  
  32. Email macneils@aol.com for questions, suggestions, problems and concerns; nothing is too small to mention.
  33.  
  34. This library is copyrighted, and is offered ╥as is.╙ Use at your own risk. Feel free to use Macneil╒s code in any freeware, shareware or commerical package. You can distribute this code anywhere, but only as long as all of the 13 text files (i.e. CDirectGWorld.cp, CCopier.cp, CCopier.h, CDirectBlit.cp, CDirectBlit.h, CDirectGWorld.h, CDirectVideo.cp, CDirectVideo.h, DirectBlitting.h, PixelTypes.h, StGWorldSetter.h, StMMUModeSwapper.h, About CDirectBlit) are together and left untouched.
  35.  
  36. Copyright ⌐ 1995, Macneil Shonle. All rights reserved.